package com.luxf.base.domainevent.rocketmq.configuration;

import com.luxf.base.domainevent.rocketmq.RocketDomainEventNoticeListenerBeanRegister;
import com.luxf.base.domainevent.rocketmq.RocketDomainEventNoticePublisher;
import com.luxf.base.domainevent.rocketmq.bootstrap.DomainEventBootstrap;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;

/**
 * @author fast66
 * 2021-05-28 9:13
 **/
@ConditionalOnProperty({"rocketmq.name-server", "rocketmq.producer.group"})
@Import({RocketDomainEventNoticeListenerContainerConfiguration.class})
@Slf4j
public class RocketDomainEventAutoConfiguration {

    @Bean
    public RocketDomainEventNoticePublisher rocketMQDomainEventNoticePublisher() {
        log.info("rocketMQDomainEventNoticePublisher init");
        return new RocketDomainEventNoticePublisher();
    }

    @Bean
    public RocketDomainEventNoticeListenerBeanRegister rocketMQDomainEventNoticeListenerBeanRegister() {
        log.info("rocketMQDomainEventNoticeListenerBeanRegister init");
        return new RocketDomainEventNoticeListenerBeanRegister();
    }

    @Bean
    public RocketMessageListenerMetadata rocketMQMessageListenerMetadata() {
        log.info("rocketMQMessageListenerMetadata init");
        return new RocketMessageListenerMetadata();
    }

    @Bean
    public DomainEventBootstrap domainEventBootstrap() {
        return new DomainEventBootstrap();
    }
}
